﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Servertest.Tools
{
    public delegate void EvenExcuteDE();

    public class EventExcuteUtil
    {
        public Mutex mutex=new Mutex();

        private static EventExcuteUtil instance;

        public static EventExcuteUtil Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new EventExcuteUtil();
                }
                return instance;
            }            
        }


        public void Excute(EvenExcuteDE de) {
            lock (this) {
                mutex.WaitOne();        //
                de();
                mutex.ReleaseMutex();
            }
        }
    }   
}

